#pragma once
#include <iostream>
#include <string>
#include <unistd.h>
#include <functional>
#include <vector>
#include <unordered_map>

typedef std::function<void()> func;

//作为回调
std::vector<func>callbacks;
std::unordered_map<int,std::string> demp;
void readMysql()
{
    std::cout<< "process[" << getpid() <<"]执行访问数据库的任务\n" << std::endl;
} 

void execuleUrl()
{
    std::cout<< "process[" << getpid() <<"]执行url解析\n" << std::endl;
}

void cal()
{
    std::cout<< "process[" << getpid() <<"]执行加密任务\n" << std::endl;
}

void save()
{
    std::cout<< "process[" << getpid() <<"]执行数据持久化任务\n" << std::endl;
}

void load()
{
    demp.insert({callbacks.size(),"readMysql: 执行访问数据库的任务"});
    callbacks.push_back(readMysql);

    demp.insert({callbacks.size(),"execuleUrl: 执行Url解析任务"});
    callbacks.push_back(execuleUrl);

    demp.insert({callbacks.size(),"cal: 执行加密任务"});
    callbacks.push_back(cal);

    demp.insert({callbacks.size(),"save: 执行数据持久化任务"});
    callbacks.push_back(save);
}
//显示处理方法
void showHandler()
{
    for(const auto& iter : demp)
    {
        std::cout<< iter.first << "\t" << iter.second << std::endl;
    }
}
//一共有多少个处理方法
int HandlerSize()
{
    return callbacks.size();
}



